package com.yunji.product.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.product.dao.IProductBrandDao;
import com.yunji.product.domain.BrandDO;
import com.yunji.product.mapper.ProductBrandMapper;
import com.yunji.product.params.BrandParam;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductBrandDaoImpl extends BaseDaoImpl<ProductBrandMapper, BrandDO> implements IProductBrandDao {
    @Override
    public List<BrandDO> search(BrandParam param) {
        return list(new LambdaQueryWrapper<BrandDO>()
                .eq(BeanUtils.isNotNull(param.getBrandId()), BrandDO::getBrandId, param.getBrandId())
                .like(BeanUtils.isNotNull(param.getBrandName()), BrandDO::getBrandName, param.getBrandName())
                .orderByAsc(BrandDO::getSort));
    }
}
